package com.mystudy.concurrent.base;

/**
 * TODO:线程的interrupt方法
 * 当调用wait，join，sleep方法对线程进行阻塞的时候，调用这个方法会清空线程的状态，并抛出InterruptedException异常
 * @author acy
 * @since 2019/05/10 18:12
 */
public class ThreadInterruptTest {
	public static void main(String[] args) throws InterruptedException {
		Thread thread = new Thread(() -> {
			while (true){
				try {
					Thread.sleep(1000);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		});
		thread.start();
		Thread.sleep(1000);
		System.out.println(thread.isInterrupted());
		thread.interrupt();
		System.out.println(thread.isInterrupted());
	}
}
